﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>


    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="stylesheet" type="text/css" href="~/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="~/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="~/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="~/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="~/static/h-ui.admin/css/style.css" />
    <title>MyCar</title>
    

</head>
<body>
    @*<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i><a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>*@
   
    <div class="page-container">
        <div class="mt-20">  
          <h3 style="margin-left:70px;">@Session["name"]购物车</h3>      
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                    <tr>
                        <td><input type="checkbox" id="checkallid" onchange="checkall()" /><span>全选</span></td>
                    </tr>
                    <tr class="text-c">
                        <th>选择</th>
                        <th>编号</th>
                        <th>花卉名称</th>
                        <th>花卉图片</th>
                        <th>单价</th>
                        <th>加车时间</th>
                        <th>购买数量</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in ViewBag.list)
                    {
                        <tr class="text-c">
                            <th><input type="checkbox" name="checkid" class="b" value="@item.Id" /></th>
                            <th>@item.Id</th>
                            <th>@item.FlowersName </th>
                            <td><input type="image" src="@item.Image" style="width:50px;height:50px;" /></td>
                            <th>@item.Selling</th>
                            <th>@item.AddTime </th>
                            <th><button onclick="jia(@item.Id)" style="width:20px;">+</button><input id="num" type="text" value="@item.ByNum" style="width:20px;text-align:center" /><button onclick="jian(@item.Id)" style="width:20px;">-</button></th>
                            <th><a href="/Home/Delete/@item.Id">删除</a></th>
                        </tr>
                    }
                </tbody>
            </table>
            <input name="" type="button" class="btn btn-success radius size-M" value="&nbsp;下&nbsp;&nbsp;&nbsp;&nbsp;单&nbsp;" onclick="addorder()">
          
        </div>
    </div>

    <script type="text/javascript" src="~/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="~/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="~/static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="~/static/h-ui.admin/js/H-ui.admin.js"></script>
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
</body>
</html>

<script>
    //全选事件
    function checkall() {

        var ck = document.getElementById("checkallid").checked;

        
        var cd = document.getElementsByName("checkid");

        for (var i in cd) {
            cd[i].checked = ck;
        }
    }
    function addorder() {
        
        var id = "";
        for (var i = 0; i < $('.b').length; i++)
        {
            if($('.b').eq(i).attr("checked")=="checked")
            {
                id += $(".b").eq(i).val() + ",";
            }
        }
        id = id.substr(0, id.length - 1);
        alert(id)
        $.ajax({
            type: "post",
            url: "/Home/AddOrder",
            data: { id: id },
            success: function (obj) {
                if (obj > 0) {
                    alert("下单成功!");
                }
                else {
                    alert("下单失败");
                    location.href = "/Home/AddOrder";
                }
            }
        })
    }
    //加
    function jia(id) {

        $.ajax({
            type: "post",
            url: "/Home/jia",
            data: { id: id },
            async: true,
            success: function (obj) {
                if (obj > 0) {
                    $("#num").val(@ViewBag.jia);
                    location.href = "/Home/MyCar"
                }
            }
        })
    }

    //减
    function jian(id) {

        $.ajax({
            type: "post",
            url: "/Home/jian",
            data: { id: id },
            async: true,
            success: function (obj) {
                if (obj > 0) {
                    $("#num").val(@ViewBag.jian);
                    location.href = "/Home/MyCar"
                }
            }
        })
    }

</script>











